package com.xl.event.listener;

import com.xl.entity.EventInfo;
import com.xl.event.ConnectedEvent;
import org.springframework.context.event.EventListener;
import org.springframework.stereotype.Component;

/**
 * 通过注解实现自定义事件的拦截器
 */
@Component
public class CustomEventListener2 {

    @EventListener
    public void listenConnectEvent(ConnectedEvent connectedEvent){
        EventInfo source =(EventInfo) connectedEvent.getSource();
        System.out.println("listenConnectEvent22222监听到连接事件，事件的内容：【"+source.getMsg()+"】");

    }
}
